/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.entidade.protocolo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;

/**
 *
 * @author roniere
 */
@Entity
public class Parcela implements Serializable {
    @Id
    @SequenceGenerator(name = "seq_parcela", sequenceName = "seq_parcela", allocationSize=1 )
    @GeneratedValue(generator = "seq_parcela", strategy = GenerationType.SEQUENCE)
    private int id; 
    
    @Column(scale= 2, precision=19)
    @NotNull
    @DecimalMin( value = "0.00" )
    @Digits( fraction = 2, integer = 10 )
    private BigDecimal valorAPagar;
        
    @Column(scale= 2, precision=19)
    @NotNull
    @DecimalMin( value = "0.00" )
    @Digits( fraction = 2, integer = 10 )
    private BigDecimal valorPago;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dataPag;
    
    private boolean ativo;

    public boolean isAtivo() {
        return ativo;
    }

    public void setAtivo(boolean ativo) {
        this.ativo = ativo;
    }

    public Date getDataPag() {
        return dataPag;
    }

    public void setDataPag(Date dataPag) {
        this.dataPag = dataPag;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public BigDecimal getValorAPagar() {
        return valorAPagar;
    }

    public void setValorAPagar(BigDecimal valorAPagar) {
        this.valorAPagar = valorAPagar;
    }

    public BigDecimal getValorPago() {
        return valorPago;
    }

    public void setValorPago(BigDecimal valorPago) {
        this.valorPago = valorPago;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Parcela other = (Parcela) obj;
        if (this.id != other.id) {
            return false;
        }
        if (this.valorAPagar != other.valorAPagar && (this.valorAPagar == null || !this.valorAPagar.equals(other.valorAPagar))) {
            return false;
        }
        if (this.valorPago != other.valorPago && (this.valorPago == null || !this.valorPago.equals(other.valorPago))) {
            return false;
        }
        if (this.dataPag != other.dataPag && (this.dataPag == null || !this.dataPag.equals(other.dataPag))) {
            return false;
        }
        if (this.ativo != other.ativo) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 17 * hash + this.id;
        hash = 17 * hash + (this.valorAPagar != null ? this.valorAPagar.hashCode() : 0);
        hash = 17 * hash + (this.valorPago != null ? this.valorPago.hashCode() : 0);
        hash = 17 * hash + (this.dataPag != null ? this.dataPag.hashCode() : 0);
        hash = 17 * hash + (this.ativo ? 1 : 0);
        return hash;
    }

    @Override
    public String toString() {
        return ""+(ativo == false ? "" :"PENDENTE PAGAMENTO") ;
    }
    
    
}
